package site.param.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import site.param.init.JsonUtil;
import site.param.init.ParameterMap;
import site.param.service.parameter.IParameterService;

import java.util.Map;

/**
 * Created by Administrator on 2017/1/13.
 */
@RestController
@RequestMapping("/load")
public class LoadParamController {
    private static Logger logger = LoggerFactory.getLogger(LoadParamController.class);
    @Autowired
    private IParameterService parameterService;

    @RequestMapping(value = "/initParamter",method = RequestMethod.POST)
    public String initParamter(String parameterMaps) {
        Map<String,ParameterMap> parameterMapMap= JsonUtil.toMap(parameterMaps);
        parameterMapMap= parameterService.initParamter(parameterMapMap);
        return JsonUtil.toJSONString(parameterMapMap);
    }
    @RequestMapping(value = "/reloadParamter",method = RequestMethod.POST)
    public String reloadParamter(String parameterMaps) {
        // 查询并返回
        ParameterMap  parameterMap= JsonUtil.toBean(parameterMaps,ParameterMap.class);
        parameterMap=parameterService.reloadParamter(parameterMap);
        return JsonUtil.toJSONString(parameterMap);
    }
}
